<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
		<div class="row">
			<div class="col-sm-12">

				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="organizationForm">
							<input type="hidden" name="id" value="${info.id}">
							<input type="hidden" name="parentId" value="${info.parentId}">

							<div class="form-group">
								<label class="col-sm-3 control-label">机构名称：</label>
								<div class="col-sm-8">
									<input type="text" id="orgName" class="form-control" name="orgName" value="${info.orgName }">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">上级机构名称：</label>
								<div class="col-sm-8">
									<input type="text" class="form-control" value="${info.parentName }">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">手机号码：</label>
								<div class="col-sm-8">
									<input type="text" class="form-control" name="phone" value="${info.phone }">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">邮箱：</label>
								<div class="col-sm-8">
									<input type="text" class="form-control" name="email" value="${info.email }">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">地址：</label>
								<div class="col-sm-8">
									<textarea class="form-control" name="address">${info.address } </textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">排序：</label>
								<div class="col-sm-8">
									<input type="number" class="form-control" min="1" max="50" name="sort" value="${info.sort }">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">状态：</label>
								<div class="col-sm-8">
									<div class="switch">
										<div class="onoffswitch">
											<input type="checkbox" name="status" <c:if test="${info.status eq '1' }"> checked</c:if> class="onoffswitch-checkbox" id="status">
											<label class="onoffswitch-label" for="status"> <span class="onoffswitch-inner"></span> <span class="onoffswitch-switch"></span>
											</label>
										</div>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">备注：</label>
								<div class="col-sm-8">
									<textarea class="form-control" name="remarks">${info.remarks } </textarea>
								</div>
							</div>
							<c:if test="${readOnly }">
								<div class="form-group">
									<label class="col-sm-3 control-label">创建人：</label>
									<div class="col-sm-8">
										<input type="text" class="form-control" value="${info.createByUserName }">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">创建时间：</label>
									<div class="col-sm-8">
										<input type="text" class="form-control" value="${fns:getFormatDateTime(info.createDate )}">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">修改人：</label>
									<div class="col-sm-8">
										<input type="text" class="form-control" value="${info.updateByUserName }">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">修改时间：</label>
									<div class="col-sm-8">
										<input type="text" class="form-control" value=" ${fns:getFormatDateTime(info.updateDate )}">
									</div>
								</div>
							</c:if>
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-2">
									<c:if test="${!readOnly   }">
										<shiro:hasPermission name="organization_update">
											<button class="btn btn-primary" type="submit">保存内容</button>
										</shiro:hasPermission>
									</c:if>
								</div>
							</div>
						</form>
						<div align="center">
							<button class="btn btn-outline btn-danger" type="" id="closeIframe">关闭</button>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
	<script type="text/javascript">
		var parentId = "${info.parentId}";
		var index = parent.layer.getFrameIndex(window.name);
		$('#closeIframe').click(function() {
			parent.layer.close(index);
		});
		$().ready(function() {
			var e = "<i class='fa fa-times-circle'></i> ";

			$("#organizationForm").validate({
				rules : {
					orgName : {
						required : true,
						minlength : 2,
						maxlength : 40
					},

					remarks : {
						maxlength : 255
					},
					address : {
						maxlength : 100
					},
					phone : {
						required : true,
						mobile : true
					},
					email : {
						email : true
					}
				},
				messages : {
					orgName : e + "${fns:getErrorMessage('ERROR_ORG_NAME')}",
					address : e + "${fns:getErrorMessage('ERROR_ADDRESS_VERY_LONG')}",
					remarks : e + "${fns:getErrorMessage('ERROR_REMARKS')}",
					phone : e + "${fns:getErrorMessage('ERROR_MOBILE')}",
					email : e + "${fns:getErrorMessage('ERROR_EMAIL')}"
				},
				submitHandler : function(form) {
					var data = formToJson("organizationForm");
					data.status = "on" == data.status ? "1" : "0";
					$.post(basePath + "/organization/save", data, function(data) {
						if (data.success) {
							succuceMsg(data.msg);
							parent.$('#organizationTree').jstree(true).refresh();
							parent.$("#queryTable").bootstrapTable('refresh');

							delayCloseParentWindow();
						} else {
							errorMsg(data.msg);
						}
					}, "json");
				}
			});
		});
	</script>
</body>
</html>